﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Control.Bus;

namespace QuanLyKho
{
    public partial class FrmQuanLyNhap : Form
    {
        BusStaff staff = new BusStaff()
        {
            ID = 1,
            UserName = "admin",
            PassWord = "admin"
        };
        List<BusImportBillDetail> Billdetails = new List<BusImportBillDetail>();
        BusImportBill Bill;
        public FrmQuanLyNhap(BusStaff _Staff)
        {
            InitializeComponent();
            staff = _Staff;
        }

        private void FrmQuanLyNhap_Load(object sender, EventArgs e)
        {

            Bill = BusImportBill.FindByDateAndStaff(dateTimePicker1.Value, staff);
            dataGridView1.AutoGenerateColumns = false;
            ChangeDatasource();
        }

        private void ChangeDatasource()
        {
            Billdetails = Bill.GetListBillDetails();
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = Billdetails;
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            Bill = BusImportBill.FindByDateAndStaff(dateTimePicker1.Value, staff);
            
            ChangeDatasource();
        }

        private void btSua_Click(object sender, EventArgs e)
        {
            Form1 frm = new Form1(Bill, staff);
            frm.ShowDialog();
            ChangeDatasource();
        }


    }
}
